package com.ybwh.springboot2.service;

import com.ybwh.springboot2.common.BusinessException;
import com.ybwh.springboot2.dao.AreaMapper;
import com.ybwh.springboot2.model.po.Area;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * <p>
 * 测试spring事务管理
 * </p>
 *
 * @author fanbeibei
 * @version V1.0
 * @since 2019/8/14 11:04
 */
@Service
public class AreaService2 {
    @Resource
    private AreaMapper areaMapper;

    @Transactional(rollbackFor = Exception.class)
    public void addAreaRollBack0(Area area) throws BusinessException {
        areaMapper.insert(area);
        throw new BusinessException("");

    }
    @Transactional(rollbackFor = Exception.class)
    public void addAreaRollBack1(Area area) throws BusinessException {
        areaMapper.insert(area);
    }



}
